//
//  UUCarPicker.m
//  UUCharterSupplier
//
//  Created by ZhangAo on 23/02/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import "UUCarPicker.h"

@interface UUCarPicker ()

@end

@implementation UUCarPicker

static UIViewController *_picker;

+ (UIViewController *)pickerWithStatus:(UUCarReviewStatus)status
                               fleetId:(NSNumber *)fleetId
       greaterThanOrEqualToCarCategory:(NSNumber *)carCategory
                         completeBlock:(void (^)(id))completeBlock {
    UUCarPicker *picker = [self listWithStatus:status];
    picker.title = @"请选择车辆";
    picker.greaterThanOrEqualToCarCategory = carCategory;
    picker.fleetId = fleetId;
    WEAK_SELF();
    picker.didSelectCarBlock = ^(id carId) {
        completeBlock(carId);
        [weakSelf dismiss];
    };
    picker.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonItemWithTitle:@"取消"
                                                                               target:self
                                                                             selector:@selector(dismiss)];
    _picker = picker;
    return [[UINavigationController alloc] initWithRootViewController:picker];
}

+ (void)dismiss {
    [_picker dismissViewControllerAnimated:YES completion:nil];
    _picker = nil;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
